// ******************************************************************
// * Copyright(c)  Steven Lu
// * Description   : Entity_PROD_PRODUCT_TEHINIC_HISTORY_ITEM
// * CreateDate    : 2011/9/27 13:27:06
// * Creater       : CodeSmith
// * LastChangeDate: 2011/9/27 13:27:06
// * LastChanger   : 2011/9/27 13:27:06
// * Version Info  : 1.0 For ESOL
// ******************************************************************

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Suzsoft.Smart.Data;
using ESOL.Common.Entity;

namespace ESOL.Business.Prod
{
    /// <summary>
    /// ProdProductTehinicHistoryItem
    /// </summary>
    public partial class ProdProductTehinicHistoryItemBs
    {
        #region GetByID
        /// <summary>
        /// Get Entity
        /// </summary>
        /// <param name="objProdProductTehinicHistoryItemEntity">Entity</param>
        /// <returns>Entity</returns>
        public static ProdProductTehinicHistoryItemEntity GetProdProductTehinicHistoryItem(ProdProductTehinicHistoryItemEntity objProdProductTehinicHistoryItemEntity)
        {
            return DataAccess.SelectSingle<ProdProductTehinicHistoryItemEntity>(objProdProductTehinicHistoryItemEntity);
        }
        #endregion


        #region Insert
        /// <summary>
        /// Insert Data
        /// </summary>
        /// <param name="objProdProductTehinicHistoryItemEntity">Entity</param>
        /// <returns>true Insert Succeed; false Insert Fail</returns>
        public static bool InsertProdProductTehinicHistoryItem(ProdProductTehinicHistoryItemEntity objProdProductTehinicHistoryItemEntity)
        {
            return DataAccess.Insert(objProdProductTehinicHistoryItemEntity);
        }

        public static bool InsertProdProductTehinicHistoryItem(List<ProdProductTehinicHistoryItemEntity> objProdProductTehinicHistoryItemEntityList)
        {
            return DataAccess.Insert(objProdProductTehinicHistoryItemEntityList);
        }
        #endregion


        #region Update
        /// <summary>
        /// Update Data
        /// </summary>
        /// <param name="objProdProductTehinicHistoryItemEntity">Entity</param>
        /// <returns>true Update Succeed; false Update Fail</returns>
        public static bool UpdateProdProductTehinicHistoryItem(ProdProductTehinicHistoryItemEntity objProdProductTehinicHistoryItemEntity)
        {
            return DataAccess.Update(objProdProductTehinicHistoryItemEntity);
        }

        public static bool UpdateProdProductTehinicHistoryItem(List<ProdProductTehinicHistoryItemEntity> objProdProductTehinicHistoryItemEntityList)
        {
            return DataAccess.Update<ProdProductTehinicHistoryItemEntity>(objProdProductTehinicHistoryItemEntityList);
        }
        #endregion


        #region Delete
        /// <summary>
        /// Delete Data
        /// </summary>
        /// <param name="objProdProductTehinicHistoryItemEntity">Entity</param>
        /// <returns>true Delete Succeed; false Delete Fail</returns>
        public static bool DeleteProdProductTehinicHistoryItem(ProdProductTehinicHistoryItemEntity objProdProductTehinicHistoryItemEntity)
        {
            return DataAccess.Delete(objProdProductTehinicHistoryItemEntity);
        }

        public static bool DeleteProdProductTehinicHistoryItem(List<ProdProductTehinicHistoryItemEntity> objProdProductTehinicHistoryItemEntityList)
        {
            return DataAccess.Delete<ProdProductTehinicHistoryItemEntity>(objProdProductTehinicHistoryItemEntityList);
        }
        #endregion


        #region GetAll
        /// <summary>
        /// Get All Data
        /// </summary>
        /// <returns>Back All Data<returns>
        public static DataSet GetProdProductTehinicHistoryItemAll()
        {
            return DataAccess.SelectAllDataSet<ProdProductTehinicHistoryItemEntity>();
        }
        /// <summary>
        /// Get All Data List
        /// </summary>
        /// <returns>Back All Data List<returns>
        public static List<ProdProductTehinicHistoryItemEntity> GetProdProductTehinicHistoryItemAllList()
        {
            return DataAccess.SelectAll<ProdProductTehinicHistoryItemEntity>();
        }
        #endregion

        #region Functions
        public static List<ProdProductTehinicHistoryItemEntity> GetListAllByHistoryID(string HistoryID)
        {
            if (string.IsNullOrEmpty(HistoryID))
                return null;
            string Sql = @"SELECT * FROM PROD_PRODUCT_TEHINIC_HISTORY_ITEM WHERE HISTORY_ID='" + HistoryID + "' ";
            Sql += " ORDER BY SEQUENCE";
            return DataAccess.Select<ProdProductTehinicHistoryItemEntity>(Sql);
        }


        public static DataTable GetDtByHistoryID(string HistoryID)
        {
            if (string.IsNullOrEmpty(HistoryID))
                return null;
            string Sql = @"SELECT PPTHI.*,PT.TECHNIC_NAME,PT.TECHNIC_CODE,MCI.ITEM_NAME,MWG.GROUP_NAME 
FROM PROD_PRODUCT_TEHINIC_HISTORY_ITEM PPTHI
LEFT JOIN PROD_TECHNIC PT ON PPTHI.TECHNIC_ID=PT.TECHNIC_ID
LEFT JOIN MST_COMMON_ITEM MCI ON PT.STATION_TYPE=MCI.ITEM_CODE
LEFT JOIN MST_WORKING_GROUP MWG ON PPTHI.GROUP_ID=MWG.GROUP_ID
                WHERE PPTHI.HISTORY_ID='" + HistoryID + "' ";
            Sql += " ORDER BY SEQUENCE";
            DataSet Ds = new DataSet();
            Ds = DataAccess.SelectDataSet(Sql);
            if (Ds.Tables[0] != null)
                return Ds.Tables[0];
            else return null;
        }
        #endregion
    }


}

